package hhpoll.service.ws;

import hhpoll.domain.User;
import hhpoll.domain.UserRegistration;
import hhpoll.service.UserService;
import hhpoll.service.context.RequestContext;

import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;


@WebService
public class UserServiceWS {

    private UserService userService;

	public UserServiceWS(UserService userService) {
        this.userService = userService;
		System.out.println("Creating UserServiceWS: userService="+userService);
	}

	@WebResult(name="user")
	public User registerUser(@WebParam(name="user")User user) {
        return userService.registerUser(user);
	}
	
	@WebResult(name="registration")
	public User activateUser(@WebParam(name="registration")UserRegistration registration) {
        return userService.activateUser(registration);
	}
	
	@WebResult(name="user")
    public User getUser(@WebParam(name="context")RequestContext context, 
    		            @WebParam(name="username")String username) {
        return userService.getUser(RequestContext.getContext(), username);
    }
}
